import {Component, Input, OnInit} from '@angular/core';
import {ModalController} from "@ionic/angular";
import {Router} from "@angular/router";

@Component({
  selector: 'app-success-tips',
  templateUrl: './success-tips.component.html',
  styleUrls: ['./success-tips.component.scss'],
})
export class SuccessTipsComponent implements OnInit {
  @Input() data: string;
  @Input() url: string;

  // 签署调查意见传参值
  @Input() summaryId: any;
  @Input() serialNo: any;
  flag = 1;
  constructor(
      private modalCtrl: ModalController,
      private router: Router,
  ) { }

  ngOnInit() {
    console.log(this.data);
    if(this.data == '初审通过'){
      this.flag = 2;
    }else if(this.data == '初审关注'){
      this.flag = 3;
    }else if(this.data == '初审拒绝') {
      this.flag = 4;
    }else if(this.data == '已提交模型审批'){
      this.flag = 5;
    }else if(this.data == '已提交风险探测'){
      this.flag = 6;
    }else if(this.data == '提交成功'){
      this.flag = 7;
    }else{
      this.flag = 1;
    }
  }



  close() {
    this.modalCtrl.dismiss({
      'dismissed': true
    });
    
    if(this.flag == 5){
      this.router.navigate([this.url], {
        queryParams: {
            summaryId: this.summaryId,
            serialNo: this.serialNo,
        }
      });
    }else{
      this.router.navigate([this.url]);
    }
  }
}
